import { Component, OnInit } from '@angular/core';
declare var $:any
@Component({
  selector: 'app-seckill',
  templateUrl: './seckill.component.html',
  styleUrls: ['./seckill.component.css']
})
export class SeckillComponent implements OnInit {
   today = Date.now();
   fixedTimezone = 1499000099990;
   reduce;
   a = 10000;
   minute=0;
   second=0;
  constructor() { }
  ngOnInit() {
    this.reduce = this.today - this.fixedTimezone;
    console.log(this.reduce);
    this.daopaji(this.a)
  };
  daopaji(a){
    var intDiff = parseInt(a);
      function timer(intDiff){
          window.setInterval(function(){
          var day=0,
              hour=0,
              minute=0,
              second=0;
          if(intDiff > 0){
              day = Math.floor(intDiff / (60 * 60 * 24));
              hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
              minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
              second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
          }
          if (minute <= 9){ this.minute = '0' + minute;}
          if (second <= 9){ this.second = '0' + second;}
          $('.hour').html(day);
          $('.min').html(hour);
          $('.miao').html(minute);
          $('.haomiao').html(second);
          intDiff--;
          }, 1000);
      } 
      $(function(){
          timer(intDiff);
      }); 
  }
}
